<template>
  <button
    class="sxk-button"
    :class="[
      `sxk-button-${type}`,
      {
        'is-plain': plain,
        'is-circle': circle,
        'is-disabled': disabled
      }
    ]"
    :disabled="disabled"
    @click="handleClick"
  >
    <sxk-icon v-if="icon" class="bottom-icon" :name="icon"></sxk-icon>
    <slot></slot>
  </button>
</template>

<script>
export default {
  name: 'sxk-button',

  props: {
    // 类型
    type: {
      type: String,
      default: 'default'
    },

    // 是否朴素按钮
    plain: {
      type: Boolean,
      default: false
    },

    // 是否圆形按钮
    circle: {
      type: Boolean,
      default: false
    },

    // 图标
    icon: {
      type: String,
      default: ''
    },

    // 是否禁用按钮
    disabled: {
      type: Boolean,
      default: false
    }
  },

  methods: {
    handleClick () {
      this.$emit('click')
    }
  }
}
</script>

<style lang="less" scoped>
// 普通按钮
.sxk-button {
  margin: 10px;
  padding: 10px 18px;
  display: inline-block;
  transition: 0.1s;
  color: #606266;
  text-align: center;
  font-weight: 500;
  background: #fff;
  border: 1px solid #dcdfe6;
  font-size: 14px;
  border-radius: 4px;
  line-height: 1;
  cursor: pointer;
}
.sxk-button:hover {
  color: #409eff;
  border-color: #c6e2ff;
  background-color: #ecf5ff;
}
.sxk-button.is-disabled {
  color: #c0c4cc;
  cursor: not-allowed;
  background-image: none;
  background-color: #fff;
  border-color: #ebeef5;
}
.sxk-button.is-disabled:hover {
  color: #c0c4cc;
  cursor: not-allowed;
  background-image: none;
  background-color: #fff;
  border-color: #ebeef5;
}

// 主要按钮
.sxk-button-primary {
  color: #fff;
  background-color: #409eff;
  border-color: #409eff;
}
.sxk-button-primary:hover {
  background: #66b1ff;
  border-color: #66b1ff;
  color: #fff;
}

// 成功按钮
.sxk-button-success {
  color: #fff;
  background-color: #67c23a;
  border-color: #67c23a;
}
.sxk-button-success:hover {
  background: #85ce61;
  border-color: #85ce61;
  color: #fff;
}

// 警告按钮
.sxk-button-warning {
  color: #fff;
  background-color: #e6a23c;
  border-color: #e6a23c;
}
.sxk-button-warning:hover {
  background: #ebb563;
  border-color: #ebb563;
  color: #fff;
}

// 危险按钮
.sxk-button-danger {
  color: #fff;
  background-color: #f56c6c;
  border-color: #f56c6c;
}
.sxk-button-danger:hover {
  background: #f78989;
  border-color: #f78989;
  color: #fff;
}

// 朴素-普通按钮
.sxk-button-primary.is-plain:hover {
  background: #fff;
  border-color: #409eff;
  color: #409eff;
}

// 朴素-主要按钮
.sxk-button-primary.is-plain {
  color: #409eff;
  background: #ecf5ff;
  border-color: #b3d8ff;
}
.sxk-button-primary.is-plain:hover {
  background: #409eff;
  border-color: #409eff;
  color: #fff;
}

// 朴素-成功按钮
.sxk-button-success.is-plain {
  color: #67c23a;
  background: #f0f9eb;
  border-color: #c2e7b0;
}
.sxk-button-success.is-plain:hover {
  background: #67c23a;
  border-color: #67c23a;
  color: #fff;
}

// 朴素-警告按钮
.sxk-button-warning.is-plain {
  color: #e6a23c;
  background: #fdf6ec;
  border-color: #f5dab1;
}
.sxk-button-warning.is-plain:hover {
  background: #e6a23c;
  border-color: #e6a23c;
  color: #fff;
}

// 朴素-危险按钮
.sxk-button-danger.is-plain {
  color: #f56c6c;
  background: #fef0f0;
  border-color: #fbc4c4;
}
.sxk-button-danger.is-plain:hover {
  background: #f56c6c;
  border-color: #f56c6c;
  color: #fff;
}

// 禁用-主要按钮
.sxk-button-primary.is-disabled {
  color: #fff;
  background-color: #a0cfff;
  border-color: #a0cfff;
}
.sxk-button-primary.is-disabled:hover {
  color: #fff;
  background-color: #a0cfff;
  border-color: #a0cfff;
}

// 禁用-成功按钮
.sxk-button-success.is-disabled {
  color: #fff;
  background-color: #b3e19d;
  border-color: #b3e19d;
}
.sxk-button-success.is-disabled:hover {
  color: #fff;
  background-color: #b3e19d;
  border-color: #b3e19d;
}

// 禁用-警告按钮
.sxk-button-warning.is-disabled {
  color: #fff;
  background-color: #f3d19e;
  border-color: #f3d19e;
}
.sxk-button-warning.is-disabled:hover {
  color: #fff;
  background-color: #f3d19e;
  border-color: #f3d19e;
}

// 禁用-危险按钮
.sxk-button-danger.is-disabled {
  color: #fff;
  background-color: #fab6b6;
  border-color: #fab6b6;
}
.sxk-button-danger.is-disabled:hover {
  color: #fff;
  background-color: #fab6b6;
  border-color: #fab6b6;
}

// 禁用-朴素-主要按钮
.sxk-button-primary.is-plain.is-disabled {
  color: #8cc5ff;
  background-color: #ecf5ff;
  border-color: #d9ecff;
}
.sxk-button-primary.is-plain.is-disabled:hover {
  color: #8cc5ff;
  background-color: #ecf5ff;
  border-color: #d9ecff;
}

// 禁用-朴素-成功按钮
.sxk-button-success.is-plain.is-disabled {
  color: #a4da89;
  background-color: #f0f9eb;
  border-color: #e1f3d8;
}
.sxk-button-success.is-plain.is-disabled:hover {
  color: #a4da89;
  background-color: #f0f9eb;
  border-color: #e1f3d8;
}

// 禁用-朴素-警告按钮
.sxk-button-warning.is-plain.is-disabled {
  color: #f0c78a;
  background-color: #fdf6ec;
  border-color: #faecd8;
}
.sxk-button-warning.is-plain.is-disabled:hover {
  color: #f0c78a;
  background-color: #fdf6ec;
  border-color: #faecd8;
}

// 禁用-朴素-危险按钮
.sxk-button-danger.is-plain.is-disabled {
  color: #f9a7a7;
  background-color: #fef0f0;
  border-color: #fde2e2;
}
.sxk-button-danger.is-plain.is-disabled:hover {
  color: #f9a7a7;
  background-color: #fef0f0;
  border-color: #fde2e2;
}

.is-circle {
  border-radius: 50%;
  padding: 0;
  text-align: center;
  height: 40px;
  width: 40px;
}
</style>
